﻿SqlHelper = {
    GetAllJob: function () {
        var me = this;
        $.request('/admin/sys/job/query/parameter', {}, function (tmp) {
            me.JobList = tmp;
        }, true, false);
    },
    GetAllPackage: function (callbackMethod, orgId) {
        var parm = {};
        if (orgId) parm.orgId = orgId;
        else if (OrgID) parm.orgId = OrgID;
        var me = this;
        $.request('/workflow/package/query/all', parm, function (list) {
            if (typeof callbackMethod == 'function') callbackMethod(list);
        }, true, false);
    },
    GetAllOrg: function () {
        var me = this;
        $.request('/admin/sys/org/query/all', {"PARENT_ID": '', "LEVEL": 1, "IS_INCLUDE_SELF": 0},
            function (tmp) {
                me.OrgList = tmp;
            }, false, false);

    },

    GetTemplateById: function (templateId) {
        var me = this;

        var template = {};

        var Data = {id: templateId}
        $.request('/workflow/template/query/id', Data, function (tmp) {

            template = tmp;

            $.each(template.activities, function (i, val) {

                for (i in ActivityPropertyStatus) {
                    var value = val.status;
                    var option = ActivityPropertyStatus[i];
                    var op = option.split('|');
                    op[0] = parseInt(op[0]);
                    op[1] = parseInt(op[1]);
                    var tmp = Math.pow(2, op[1]) - 1;
                    val[i] = tmp & (value >> (op[0]));
                }
            })
        }, false, false);
        return template;
    },

    GetAllTemplate: function (parm) {
        var me = this;
        $.request('/workflow/template/all', parm, function (tmp) {
            me.TemplateList = tmp;
            return tmp;
        }, false, false);
    }
}

